# -*- coding: utf-8 -*-
from scipy import ndimage
from skimage import data,util
from matplotlib import pyplot as plt

#载入图片
img=data.astronaut()[:,:,0]#选取红色通道(变成灰度图)
#加入胡椒噪声
pepper_img=util.random_noise(img,mode='pepper',seed=None,clip=True)
#对图像加入盐粒噪声
salt_img=util.random_noise(img,mode='salt',seed=None,clip=True)

n=3
max_img=ndimage.maximum_filter(pepper_img,(n,n))
#plt.imshow(max_img,cmap='gray')
min_img=ndimage.minimum_filter(salt_img,(n,n))
#plt.imshow(min_img,cmap='gray')


